////////////////////////////////////////////////////////////////////////////////
//
//  nino
//
////////////////////////////////////////////////////////////////////////////////

package ochart.utils.logging
{
	
	/**
	 * 定义日志的优先级
	 */
	public class Priority
	{
		public static const DEBUG_STRING:String = "debug";
		public static const DEBUG_INT:int = 0;
		
		public static const INFO_STRING:String = "info";
		public static const INFO_INT:int = 1;
		
		public static const WARN_STRING:String = "warn";
		public static const WARN_INT:int = 2;
		
		public static const ERROR_STRING:String = "error";
		public static const ERROR_INT:int = 3;
		
		public static const FATAL_STRING:String = "fatal";
		public static const FATAL_INT:int = 4;
		
		public var level:int = 0;
		public var levelStr:String = null;
		
		public function Priority(level:int = 0)
		{
			this.level = level;
			this.levelStr = intToString(level);
		}
		
		/**
		 * 优先级是否大于值的优先级
		 */
		public function isGreaterOrEqual(priority:Priority):Boolean
		{
			return level >= priority.level;
		}
		
		public function toString():String
		{
			return levelStr;
		}
		
		public function intToString(value:int):String
		{
			switch(value)
			{
				case FATAL_INT:
					return FATAL_STRING;
				case ERROR_INT:
					return ERROR_STRING;
				case WARN_INT:
					return WARN_STRING;
				case INFO_INT:
					return INFO_STRING;
				case DEBUG_INT:
					return DEBUG_STRING;
			}
			return null;
		}
	}
}